package com.example.androidpattern;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

import com.example.androidpattern.adapter.AdapterActivity;
import com.example.androidpattern.bridge.BridgeActivity;
import com.example.androidpattern.decorator.DecoratorActivity;
import com.example.androidpattern.factory.FactoryActivity;
import com.example.androidpattern.observer.ObserverActivity;
import com.example.androidpattern.proxy.ProxyActivity;
import com.example.androidpattern.state.StateActivity;
import com.example.androidpattern.strategy.StrategyActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

public class MainActivity extends AppCompatActivity {

    @BindView(R.id.btn_main_observer)
    Button btnMainObserver;
    @BindView(R.id.btn_main_factory)
    Button btnMainFactory;
    @BindView(R.id.btn_main_strategy)
    Button btnMainStrategy;
    @BindView(R.id.btn_main_adapter)
    Button btnMainAdapter;
    private Unbinder mUnbinder;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mUnbinder = ButterKnife.bind(this);
    }

    @OnClick({R.id.btn_main_observer,
            R.id.btn_main_factory,
            R.id.btn_main_strategy,
            R.id.btn_main_adapter,
            R.id.btn_main_state,
            R.id.btn_main_proxy,
            R.id.btn_main_bridge,
            R.id.btn_main_decorator})
    public void onViewClicked(View view) {
        Intent intent = null;
        switch (view.getId()) {
            case R.id.btn_main_observer:
                intent = new Intent(MainActivity.this, ObserverActivity.class);
                break;
            case R.id.btn_main_factory:
                intent = new Intent(MainActivity.this, FactoryActivity.class);
                break;
            case R.id.btn_main_strategy:
                intent = new Intent(MainActivity.this, StrategyActivity.class);
                break;
            case R.id.btn_main_adapter:
                intent = new Intent(MainActivity.this, AdapterActivity.class);
                break;
            case R.id.btn_main_state:
                intent = new Intent(MainActivity.this, StateActivity.class);
                break;
            case R.id.btn_main_proxy:
                intent = new Intent(MainActivity.this, ProxyActivity.class);
                break;
            case R.id.btn_main_bridge:
                intent = new Intent(MainActivity.this, BridgeActivity.class);
                break;
            case R.id.btn_main_decorator:
                intent = new Intent(MainActivity.this, DecoratorActivity.class);
                break;
        }
        if (intent != null) {
            startActivity(intent);
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mUnbinder.unbind();
    }
}
